#include "NamedPipe.hpp"
#include "log.hpp"
// 当前进程负责创建管道并读取
int main() {
    // 创建管道
    if(mkfifo(NPIPE_NAME, DEFAULT_MODE) == -1) {
        perror("mkfifo");
        exit(CREATE_ERR);
    }
    RDNamedPipe pipef;
    logger log;
    log(INFO, "server open file done");
    while(1) {
        string buf;
        ssize_t n = pipef.Read(&buf);
        if(n == 0){
            log(WARNING, "client quit, read end of pipe");
            break;
        }
        cout << "client say# " << buf << endl;
    }
    
    return 0;
}